﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using 书易.Model;

namespace 书易.DAL
{
    public class AdminDal
    {
        public static Admin selectAdmin(string name,string pwd) {
            using (SqlDataReader dar = DbHelper.ExecuteReader("select * from Admin where APassword=@APassword and AName=@AName", new SqlParameter[] {
                new SqlParameter("@APassword",pwd),
                new SqlParameter("@AName",name),
            }))
            {
                if (dar.Read())
                {
                    Admin a = new Admin();
                    a.AName = Convert.ToString(dar["AName"]);
                    a.APassword = Convert.ToString(dar["APassword"]);
                    a.AID = Convert.ToInt32(dar["AID"]);
                    return a;
                }
                else {
                    return null;
                }
            }
            
        }
    }
}
